import { PrefabPath } from "../config/PrefabPath";
import LayerBase from "../core/common/LayerBase";
import UIManager from "../core/managers/UIManager";
import { UserStore } from "../core/store/UserStore";
import { observer, render } from "../mobx/observer";

const { ccclass, property } = cc._decorator;
@ccclass
@observer
export default class GameMainLayer extends LayerBase {

    @property({ type: cc.Button, tooltip: '开始按钮' })
    btnStart: cc.Button = null;

    onLoad() {
        this.initEvent();
    }
    initEvent() {
        this.btnStart.node.on(cc.Node.EventType.TOUCH_START, this.onGameStart, this);
    }
    async onGameStart() {
        await UIManager.show(PrefabPath.gameLayer);
        UIManager.hide(PrefabPath.gameMainLayer)
    }

    onSetting() {
        UIManager.show(PrefabPath.setting);
    }

    onTurn() {
       UserStore.Ins.clear();
       cc.game.restart()
    }
    @render
    setMusicVolume() {
        cc.audioEngine.setEffectsVolume(UserStore.Ins.effectVoice);
        cc.audioEngine.setMusicVolume(UserStore.Ins.musicVoice);
    }
}